package a66weding.com.jiehuntong.activity.home;

import android.os.Bundle;
import android.view.View;
import android.view.Window;

import a66weding.com.jiehuntong.application.DataWareHourse;
import a66weding.com.jiehuntong.application.GlobalApplication;
import a66weding.com.jiehuntong.beans.User;
import a66weding.com.jiehuntong.common.utils.CUtils;
import me.imid.swipebacklayout.lib.app.SwipeBackActivity;

/**
 * @version :
 * @creator : AxDu
 * @create-time : 2016/7/19
 * @description :
 */
public class BaseHomeActivity extends SwipeBackActivity {

    protected static final int HAVEDATA=1;
    protected static final int NODATA=0;
    protected static final int DATAERROR=2;
    protected static final int LOADINGDATA=3;
    protected static final int NONET=4;
    protected User user;
    private boolean islogin;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        islogin = ((GlobalApplication) getApplication()).isLogin();
        if(islogin) {
            user = DataWareHourse.getInstance().getmUser();
        }
    }
    protected void refreshViewLay(int state,View mContentLay,View mProgressLay,View mNonetLay){
        switch (state) {
            case HAVEDATA:
                mProgressLay.setVisibility(View.GONE);
                if(mContentLay.isShown()) {
                    return;
                }else{
                    mContentLay.setVisibility(View.VISIBLE);
                }
                mProgressLay.setVisibility(View.GONE);
                mNonetLay.setVisibility(View.GONE);
                break;
            case NODATA:
                mProgressLay.setVisibility(View.VISIBLE);
                mContentLay.setVisibility(View.GONE);
                mNonetLay.setVisibility(View.GONE);
                break;
            case NONET:
                mProgressLay.setVisibility(View.GONE);
                mContentLay.setVisibility(View.GONE);
                mNonetLay.setVisibility(View.VISIBLE);
                break;
        }
    }

    @Override
    protected void onStop() {
        super.onStop();
        CUtils.cancelToast();
    }

    @Override
    protected void onDestroy() {
        CUtils.cancelToast();
        super.onDestroy();
    }
}
